#!/bin/bash

# 🚀 翼支付金豆脚本 - Gitee上传一键执行脚本
# 适用于已创建Gitee仓库的情况

echo "=================================="
echo "🚀 翼支付金豆脚本 - Gitee上传工具"
echo "=================================="
echo ""

# 检查是否在项目目录
if [ ! -f "package.json" ]; then
    echo "❌ 错误：未找到package.json文件"
    echo "请确保在项目根目录中运行此脚本"
    exit 1
fi

# 检查Git状态
echo "📊 检查Git状态..."
git status

# 确认推送
echo ""
echo "🔧 将要执行的操作："
echo "1. 设置Gitee远程仓库：https://gitee.com/17503995945/电信金豆.git"
echo "2. 推送到main分支"
echo ""
read -p "确认继续？(y/N): " confirm

if [[ $confirm != [yY] ]]; then
    echo "操作已取消"
    exit 0
fi

echo ""
echo "🔗 配置远程仓库..."
git remote set-url origin https://gitee.com/17503995945/电信金豆.git
echo "✅ 远程仓库已配置"

echo ""
echo "📤 开始推送代码..."
echo ""

# 执行推送
git push -u origin main

# 检查推送结果
if [ $? -eq 0 ]; then
    echo ""
    echo "🎉 推送成功！"
    echo ""
    echo "📱 项目访问地址："
    echo "  - 项目主页: https://gitee.com/17503995945/电信金豆"
    echo "  - 代码浏览: https://gitee.com/17503995945/电信金豆/tree/main"
    echo ""
    echo "🔄 后续更新代码："
    echo "  git add ."
    echo "  git commit -m '更新说明'"
    echo "  git push"
    echo ""
else
    echo ""
    echo "❌ 推送失败，请检查："
    echo "1. Gitee仓库是否已创建"
    echo "2. 用户名和密码是否正确"
    echo "3. 网络连接是否正常"
    echo ""
    echo "📖 详细说明请查看: GITEE_COMPLETE_GUIDE.md"
fi

echo ""
echo "=================================="
echo "脚本执行完成"
echo "=================================="